import 'package:flutter/widgets.dart';

final SlidePageRoute = (Widget page) => PageRouteBuilder(
  pageBuilder: (context, animation, secondaryAnimation) => page,
  transitionsBuilder: (context, animation, secondaryAnimation, child) {
    // 定义滑动的起始和结束位置
    const begin = Offset(1.0, 0.0); // 从右侧开始
    const end = Offset.zero;
    const curve = Curves.easeInOut;
    // 创建一个 Tween 用于控制偏移量
    var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
    return SlideTransition(
      position: animation.drive(tween),
      child: child,
    );
  },
  transitionDuration: const Duration(milliseconds: 500),
);